import typing as t

import strawberry
from app.api.graphql.base import default_resolver
from app.api.graphql.mutations.auth import login_field
from app.api.graphql.mutations.auth import Token
from app.api.graphql.mutations.user import add_user_field
from app.api.graphql.mutations.user_relationship import block_field
from app.api.graphql.mutations.user_relationship import follow_field
from app.api.graphql.mutations.user_relationship import unblock_field
from app.api.graphql.mutations.user_relationship import unfollow_field
from app.api.graphql.types import IsOk
from app.api.graphql.types.user import DisplayUser
from app.api.graphql.types.user import users_field
from app.api.graphql.types.user_relationship import UserRelationship
from app.common.auth import Login


@strawberry.type
class Query:
    users: t.List[DisplayUser] = users_field
    user_relationship: UserRelationship = strawberry.field(
        permission_classes=[Login], resolver=default_resolver
    )  # 此处聚合 用户关系 相关的字段查询


@strawberry.type
class Mutation:
    add_user: t.List[DisplayUser] = add_user_field
    login: Token = login_field
    block: IsOk = block_field
    unblock: IsOk = unblock_field
    follow: IsOk = follow_field
    unfollow: IsOk = unfollow_field


schema = strawberry.Schema(query=Query, mutation=Mutation)
